<template>
  <div>
    <li v-for="(item,index) in a " :key="index">{{ item }}<button @click="del(index)" id="index">删除</button></li>
    <br>
    <button @click="get">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      a : [],
    };
  },
  methods: {
    get() {
      this.a.push (Math.round(Math.random() * 20));
    },
    del(index){
      this.a.splice(index,1);
    }
  },
};
</script>

<style scoped></style>
